package com.he.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.he.util.PinYinUtil;
import com.he.dao.CityMapper;
import com.he.entity.City;
import com.he.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements ICityService {

    @Autowired
    private CityMapper cityMapper;

    @Override
    public boolean save(City entity) {
        String pinYin = PinYinUtil.str2PinYin(entity.getCityName());
        System.out.println(pinYin);
        entity.setCityPinyin(pinYin);
        return super.save(entity);
    }

    @Override
    @Transactional
    public int updateCityHNumber(Integer cid, Integer number) {
        return cityMapper.updateCityHNUmber(cid, number);
    }
}
